package memento;

public class MementoPattern {

    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();
        Originator originator = new Originator();

        originator.setState("healthy");
        System.out.println(originator.getState());

        caretaker.saveMemento(originator.createMemento());

        originator.setState("hungry");
        System.out.println(originator.getState());

        originator.restoreMemento(caretaker.getMemento());
        System.out.println(originator.getState());

        caretaker.saveMemento(originator.createMemento());

        originator.setState("dead");
        System.out.println(originator.getState());

        originator.restoreMemento(caretaker.getMemento());
        System.out.println(originator.getState());
    }
}
